﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DesignPatternsDemo
{
    public class Factory
    {
        public enum ProductType
        {
            Fridge,
            Dishwasher
        }

        public static IProduct GetProduct(ProductType pt)
        {
            switch (pt)
            {
                case ProductType.Fridge:
                    return new Fridge();
                case ProductType.Dishwasher:
                    return new Dishwasher();
                default:
                    throw new NotImplementedException();
            }
        }
    }

    public interface IProduct
    {
        void Use();
    }

    public class Fridge : IProduct
    {
        public Fridge()
        {
            Console.WriteLine("Creating a fridge"); 
        }

        public void Use()
        {
            Console.WriteLine("Now using a fridge");
        }
    }

    public class Dishwasher : IProduct
    {
        public Dishwasher()
        {
            Console.WriteLine("Creating a dishwasher");
        }

        public void Use()
        {
            Console.WriteLine("Now using a dishwasher");
        }
    }
}
